package com.example.product.statemachine;

import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.*;

public class PD extends EnumStateMachineConfigurerAdapter<PDStates, PDEvent> {


    @Override
    public void configure(StateMachineStateConfigurer<PDStates, PDEvent> states) throws Exception {
        states.withStates()
                .initial(PDStates.STATE1)
                .state(PDStates.STATE2)
                .state(PDStates.STATE3)
                .state(PDStates.STATE4);
    }

    @Override
    public void configure(StateMachineTransitionConfigurer<PDStates, PDEvent> transitions) throws Exception {
        transitions.withExternal()
                .source(PDStates.STATE1)
                .target(PDStates.STATE2)
                .event(PDEvent.EVENT1)
                .and()
                .withExternal()
                .source(PDStates.STATE2)
                .target(PDStates.STATE3)
                .event(PDEvent.EVENT2)
                .and()
                .withExternal()
                .source(PDStates.STATE3)
                .target(PDStates.STATE4);
    }
}
